const db = require("../db/index");
//获取特定deveui的传感器 相关信息
async function getSensor(deveui) {
  let sql_query = `select * from sensor_list where term_deveui = ?`;
  return await new Promise((resolve, reject) => {
    db.query(sql_query, deveui, (err, result) => {
      if (err) {
        reject(err);
      }
      resolve(result);
    });
  });
}
//获取数据类型的相关信息
async function getDataType(type_data_id) {
  let sql_query = `select * from type_data where id = ?`;
  return await new Promise((resolve, reject) => {
    db.query(sql_query, type_data_id, (err, result) => {
      if (err) {
        reject(err);
      }
      resolve(result);
    });
  });
}

module.exports.getSensor = getSensor;
module.exports.getDataType = getDataType;
